﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Projektet.Model
{
    class CatapultShot : Projectile
    {        
        public CatapultShot(Vector2 startPosition, Vector2 velocity) 
        {
            _gravity = new Vector2(0f, 0.001f);
            _position = startPosition;
            _velocity = velocity;
            _damage = 10;

            _width = 2;
            _height = 2;
        }

        public void DidHit(ExplosionListener expListener, List<CombatUnit> unitList)
        {
            foreach (CombatUnit cU in unitList)
            {
                if (_hitRectangle.Intersects(cU._unitRect))
                {
                    cU.TakeDamage(_damage);
                    expListener.CreateExplosion(_position);
                }
            }
        }

        public bool ShotExpired(ExplosionListener expListener) 
        {
            if(_position.Y > -80)
            {
                expListener.CreateExplosion(_position);
            }
            if (_position.Y > 10)
            {
                return true;
            }
            return false;
        }
    }
}
